//
//  StrategyForeignAddressTableViewCell.m
//  ITrip
//
//  Created by dllo on 15/5/29.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "StrategyForeignAddressTableViewCell.h"

@implementation StrategyForeignAddressTableViewCell

- (void)dealloc
{
    [self.address_attraction_trips_countLabel release];
    [self.address_attraction_trips_countView release];
    [self.address_descriptionLabel release];
    [self.address_imageview release];
    [self.address_nameLabel release];
    [super dealloc];
}

- (void)setForeignAddressModel:(StrategyForeignAddressModel *)foreignAddressModel
{
    _address_attraction_trips_countLabel.text = [NSString stringWithFormat:@"%ld 篇游记", foreignAddressModel.address_attraction_trips_count];
    _address_descriptionLabel.text = foreignAddressModel.address_description;
    [_address_imageview setImageWithURL:[NSURL URLWithString:foreignAddressModel.address_image_url] placeholderImage:[UIImage imageNamed:@"defaultPicture"]];
    _address_nameLabel.text = foreignAddressModel.address_name;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createMyView];
    }
    return self;
}

- (void)createMyView
{
    self.address_imageview = [[UIImageView alloc]init];
    [self.contentView addSubview:self.address_imageview];
    
    self.address_attraction_trips_countView = [[UIView alloc]init];
    [self.address_imageview addSubview:self.address_attraction_trips_countView];
    
    self.address_attraction_trips_countLabel = [[UILabel alloc]init];
    [self.address_imageview addSubview:self.address_attraction_trips_countLabel];
    
    self.address_descriptionLabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.address_descriptionLabel];
    
    self.address_nameLabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.address_nameLabel];
    
    [self.address_attraction_trips_countLabel release];
    [self.address_attraction_trips_countView release];
    [self.address_descriptionLabel release];
    [self.address_imageview release];
    [self.address_nameLabel release];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.address_imageview.frame = CGRectMake(5, 5, 150, 100);
    self.address_imageview.backgroundColor = [UIColor colorWithRed:227/255.0 green:233/255.0 blue:240/255.0 alpha:1];
    
    self.address_attraction_trips_countView.frame= CGRectMake(0, 80, 150, 20);
    self.address_attraction_trips_countView.backgroundColor = [UIColor blackColor];
    self.address_attraction_trips_countView.alpha = 0.5;
    
    self.address_attraction_trips_countLabel.frame = CGRectMake(0, 80, 150, 20);
    self.address_attraction_trips_countLabel.backgroundColor = [UIColor clearColor];
    self.address_attraction_trips_countLabel.textColor = [UIColor whiteColor];
    self.address_attraction_trips_countLabel.textAlignment = NSTextAlignmentCenter;
    self.address_attraction_trips_countLabel.font = [UIFont systemFontOfSize:15];
    
    self.address_nameLabel.frame = CGRectMake(160, 5, self.frame.size.width - 185, 40);
    self.address_nameLabel.backgroundColor = [UIColor whiteColor];
    
    self.address_descriptionLabel.frame = CGRectMake(160, 45, self.frame.size.width - 185, 60);
    self.address_descriptionLabel.backgroundColor = [UIColor whiteColor];
    self.address_descriptionLabel.font = [UIFont systemFontOfSize:16];
    self.address_descriptionLabel.numberOfLines = 3;
    [self.address_descriptionLabel sizeToFit];
    
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
